//key 声明一个变量
const TOKEN_KEY = 'hmtt_76'
//保存token
export const setToken = (tokenObj) =>{
    window.localStorage.setItem(TOKEN_KEY,JSON.stringify(tokenObj))
}
//获取token
export const getToken = () =>{
    return JSON.parse(window.localStorage.getItem(TOKEN_KEY))
}
//删除token
 export const removeToken = () =>{
     window.localStorage.removeItem(TOKEN_KEY)
 }

 const CHANNEL_KEY = 'HMNEWS-CHANNELS'
// 存频道信息
export const saveChannels = (list) => {

  window.localStorage.setItem(CHANNEL_KEY, JSON.stringify(list))
}

// 取频道信息
export const getChannels = () => {

  return JSON.parse(window.localStorage.getItem(CHANNEL_KEY))
}

// 删除频道信息
export const removeChannels = () => {

  window.localStorage.removeItem(CHANNEL_KEY)
}

const HISTORY_KEY = 'HMNEWS-HISTORY'
// 存历史记录
export const saveHistory = (list) => {

  window.localStorage.setItem(HISTORY_KEY, JSON.stringify(list))
}

// 取历史记录
export const getHistory = () => {

  return JSON.parse(window.localStorage.getItem(HISTORY_KEY))
}

// 删除历史记录
export const removeHistory = () => {

  window.localStorage.removeItem(HISTORY_KEY)
}